<div id="nav" class="mainnav_title">
    <ul>
      <a class="on" href="{:U('citybelong/add',array('t'=>$types))}">添加</a>
    </ul>
</div>
<form id="myform" action="{:U('citybelong/add', array('t'=>$types))}" method="post" class="validate" target="main">
    <input type="hidden" name="types" value="{$types}" />
    <table border="0" cellspacing="0" cellpadding="0"  class="table_form" width="100%">
        <tr>
            <td align="right" width="90"><span class="red">*</span>所属城市</td>
            <td>
                <select id="sel_1">
                  <volist name="areas[0]" id="vo">
                     <option value="{$vo.id}">{$vo.names}</option>
                  </volist>
                </select>
                <select id="sel_2" name="cid2">
                  <volist name="areas[1]" id="vo">
                     <option value="{$vo.id}">{$vo.names}</option>
                  </volist>
                </select>
                <select id="sel_3" name="cid1">
                  <volist name="areas[2]" id="vo">
                     <option value="{$vo.id}">{$vo.names}</option>
                  </volist>
                </select>
                <select id="sel_4" name="cid">
                  <volist name="areas[3]" id="vo">
                     <option value="{$vo.id}">{$vo.names}</option>
                  </volist>
                </select>
             </td>
        </tr>
        <neq name="message" value="">
        <tr>
          <td></td>
          <td>
           <span id="msg_names" class="msg1">{$message}</span>
          </td>
        </tr>
        </neq>
        <tr>
            <td align="right"><span class="red">*</span>排序</td>
            <td colspan="2"><input name="sort" type="text" id="sort" value='' validate="required:true,number:true,min:0" class="txt" datatype="n" nullmsg="请填写排序" errmsg="请填写数字" sucmsg=" " /></td>
        </tr>
    </table>
    <div id="btnbox" class="btn">
        <INPUT TYPE="submit" name="submit" value=" 保 存 " class="button" >
        <input TYPE="reset"  value=" 重 置 " class="button">
    </div>
</form>
<script type="text/javascript">
/*
 * citybelong 所属城市四级联动下拉菜单
 */
$(function($){
   $("#sel_1").change(sel1);
   $("#sel_2").change(sel2);
   $("#sel_3").change(sel3);
});
function sel1(){
  $.ajax({
	  type:"get",
	  url:"{:U('citySelect')}",dataType:"json",
	  data:{ciy:$("#sel_1").val()},
	  success: function(sel_2){
		  $("#sel_4").hide();
		  $("#sel_3").hide();
		  $("#sel_2").hide();
		  $("#sel_2").empty();
		  if(sel_3 != null){
			for(s in sel_2){
				$("#sel_2").append("<option value='"+ sel_2[s].id +"'>"+ sel_2[s].names +"</option>");
			}
			$("#sel_2").show();
			sel2();
		  }
	  }}); 
}
function sel2(){
  $.ajax({
	  type:"get",
	  url:"{:U('citySelect')}",dataType:"json",
	  data:{ciy:$("#sel_2").val()},
	  success: function(sel_3){
		  $("#sel_4").hide();
		  $("#sel_3").hide();
		  $("#sel_3").empty();
		  if(sel_3 != null){
			for(s in sel_3){
				$("#sel_3").append("<option value='"+ sel_3[s].id +"'>"+ sel_3[s].names +"</option>");
			}
			$("#sel_3").show();
			sel3();
		  }
	  }}); 
}
function sel3(){
  $.ajax({
	  type:"get",
	  url:"{:U('citySelect')}",dataType:"json",
	  data:{ciy:$("#sel_3").val()},
	  success: function(sel_4){
		  $("#sel_4").hide();
		  $("#sel_4").empty();
		  if(sel_4 != null){
			for(s in sel_4){
				$("#sel_4").append("<option value='"+ sel_4[s].id +"'>"+ sel_4[s].names +"</option>");
			}
			$("#sel_4").show();
		  }
	  }}); 
}
/** citybelong 所属城市四级联动下拉菜单 **/
</script>